<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%--
  Created by IntelliJ IDEA.
  User: zzf
  Date: 2021/1/7
  Time: 10:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
<%--    <script src="${pageContext.request.contextPath}/script/jquery-1.7.2.js"></script>--%>
    <script>
        $(function (){
            $(".removeAnchor").click(function (){
                if (!confirm("确定要删除吗？")){
                    return false;
                }
                $("#convertForm").attr("action",this.href).submit();
                return false;
            })
        })
    </script>
    <style type="text/css">
        /*table {*/
        /*    border: 5px solid black;*/
        /*    border-collapse: collapse;*/
        /*    margin-left: auto;*/
        /*    margin-right: auto;*/
        /*}*/

        /*table td,th {*/
        /*    border: 1px solid black;*/
        /*}*/
        .container {
            position:absolute;

            left:1200px;

            top:400px;
        }
    </style>
</head>
<body>
<a href="${pageContext.request.contextPath}">首页</a><br><br><br>
<table class="table table-hover">
    <c:if test="${empty requestScope.pageInfo.list}">
        <tr>
            <td>抱歉！没有查询到您需要的数据！</td>
        </tr>
    </c:if>
    <c:if test="${not empty requestScope.pageInfo.list}">
        <thead>
        <tr class="table-primary">
            <th>ID</th>
            <th>葫芦娃姓名</th>
            <th>葫芦娃特征</th>
            <th>葫芦娃能力</th>
            <th>删除</th>
            <th>更新</th>
        </tr>
        </thead>
    <tbody>
    <c:forEach items="${requestScope.pageInfo.list}" var="gb">
        <tr class="table-info">
            <td>${gb.id}</td>
            <td>${gb.name}</td>
            <td>${gb.color}</td>
            <td>${gb.gbDescribe}</td>
            <td><a href="${pageContext.request.contextPath}/gb/${gb.id}" class="removeAnchor">删除</a></td>
            <td><a href="${pageContext.request.contextPath}/gb/${gb.id}">修改</a></td>
        </tr>
    </c:forEach>
    </tbody>
    </c:if>
    <tr class="table-danger">
        <td colspan="6" style="text-align: center"><a href="${pageContext.request.contextPath}/gb/add">添加新葫芦娃</a></td>
    </tr>
    <form id="convertForm" method="post">
        <input type="hidden" name="_method" value="delete"/>
    </form>

    <div class="container">
        <ul class="pagination">
            <c:if test="${requestScope.pageInfo.prePage == 0}">
                <li class="page-item"><a class="page-link" href="${pageContext.request.contextPath}/gb/list/1">上一页</a></li>
            </c:if>
            <c:if test="${requestScope.pageInfo.prePage != 0}">
                <li class="page-item"><a class="page-link" href="${pageContext.request.contextPath}/gb/list/${requestScope.pageInfo.prePage}">上一页</a></li>
            </c:if>

            <c:forEach begin="1" end="${requestScope.pageInfo.pages}" var="page">
                <c:if test="${requestScope.pageInfo.pageNum == page}">
                    <li class="page-item active"><a class="page-link" href="${pageContext.request.contextPath}/gb/list/${page}">${page}</a></li>
                </c:if>
                <c:if test="${requestScope.pageInfo.pageNum != page}">
                    <li class="page-item"><a class="page-link" href="${pageContext.request.contextPath}/gb/list/${page}">${page}</a></li>
                </c:if>
            </c:forEach>
            <c:if test="${requestScope.pageInfo.nextPage == 0}">
                <li class="page-item"><a class="page-link" href="${pageContext.request.contextPath}/gb/list/1">下一页</a></li>
            </c:if>
            <c:if test="${requestScope.pageInfo.nextPage != 0}">
                <li class="page-item"><a class="page-link" href="${pageContext.request.contextPath}/gb/list/${requestScope.pageInfo.nextPage}">下一页</a></li>
            </c:if>

        </ul>
    </div>
</table>

</body>
</html>
